package com.ghpt.controller;
import com.ghpt.pojo.DianJieCao;
import com.ghpt.service.DianJieCaoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping("/dianjiecao")
public class DianJieCaoController {
    private final DianJieCaoService dianJieCaoService;

    public DianJieCaoController(DianJieCaoService dianJieCaoService) {
        this.dianJieCaoService = dianJieCaoService;
    }
    @GetMapping("/{id}")
    public DianJieCao getDianJieCaoById(@PathVariable Long id) {
        System.out.println("结果是"+dianJieCaoService.findDianJieCaoById(id));
        return dianJieCaoService.findDianJieCaoById(id);
    }
    @PutMapping
    public int updateDianJieCao(@RequestBody DianJieCao dianJieCao) {
        return dianJieCaoService.updateById(dianJieCao);
    }
}
